﻿namespace GxFramework
{
    public class Sequence:CompositeWork
    {
        int _finishNum;
        protected override bool OnEnter()
        {
            _finishNum = 0;
            return this.childCount != 0;
        }
        protected override WorkStatus Update(WorkStatus status)
        {
            if (status == WorkStatus.Success)
                ++_finishNum;

            if (_finishNum == this.childCount)
                return WorkStatus.Success;

            var subWork = this.GetChildAt(_finishNum);

            return subWork.Exec(status);
        }
    }
}
